db_constraints.constraints

User-defined attributes that can be used with the KeyedItem mixin. The constraints module contains: $(TOC UniqueConstraintColumn) $(TOC PrimaryKeyColumn) $(TOC ExclusionConstraint) $(TOC CheckConstraint) $(TOC NotNull) $(TOC SetConstraint) $(TOC EnumConstraint) $(TOC Rule) $(TOC ForeignKey) $(TOC ForeignKeyConstraint) $(TOC Default)

Members

Aliases

NotNull
alias NotNull = CheckConstraint!(function bool(auto ref a), "NotNull")

Alias for a special check constraint that makes sure the column is never null. This is checked the same time as all the other check constraints. The name of the constraint is NotNull in the error messages if this is ever violated.

PrimaryKeyColumn
alias PrimaryKeyColumn = UniqueConstraintColumn!("PrimaryKey")

An alias for the primary key column. A member with this attribute must also have the NotNull attribute.

Enums

Rule
enum Rule

Rules for foreign keys when updating or deleting.

Structs

CheckConstraint
struct CheckConstraint(alias check_, string name_ = "")

$(WIKI keyeditem, KeyedItem.checkConstraints) will check all of the members marked with this attribute and use the check given.

Default
struct Default(alias value_)

Default used with $(SRCTAG Rule.setDefault) for foreign keys.

ExclusionConstraint
struct ExclusionConstraint(alias exclusion_, string name_ = "")

Mimics Postgresql's Exclude Constraint. This will exclude any items that return true to the exclusion_.

ForeignKey
struct ForeignKey(string name_, string[] columnNames_, string referencedTableName_, string[] referencedColumnNames_, Rule updateRule_, Rule deleteRule_)

$(SRCTAG ForeignKeyConstraint) should be used instead of this struct. This is more the behind the scenes struct.

UniqueConstraintColumn
struct UniqueConstraintColumn(string name_)

KeyedItem will create a struct with name defined in the compile-time argument. For example a property marked with @UniqueColumn!("uc_Person") will be part of the struct uc_Person.

Templates

EnumConstraint
template EnumConstraint(values...)
template EnumConstraint(bool isStrict, values...)

Alias for check constraint that makes sure the property that has this attribute only contains a member that is part of the enumeration. This should act like the ENUM constraint in MySQL. This does modify the value coming in. This is only for strings.

ForeignKeyConstraint
template ForeignKeyConstraint(string name_, string[] columnNames_, string referencedTableName_, string[] referencedColumnNames_, Rule updateRule_, Rule deleteRule_)
template ForeignKeyConstraint(string[] columnNames_, string referencedTableName_, string[] referencedColumnNames_, Rule updateRule_, Rule deleteRule_)
template ForeignKeyConstraint(string name_, string[] columnNames_, string referencedTableName_, string[] referencedColumnNames_)
template ForeignKeyConstraint(string[] columnNames_, string referencedTableName_, string[] referencedColumnNames_)

The foreign key user-defined attribute.

SetConstraint
template SetConstraint(values...)
template SetConstraint(bool isStrict, values...)

Alias for check constraint that makes sure the property that has this attribute only contains members in the set. This should act like the SET constraint in MySQL. It will sort and remove the duplicates of the SET. This does modify the value coming in. This is only for strings.

Meta

License

$(GPL2)

Authors

Matthew Armbruster

Source: $(SRC $(SRCFILENAME))